package com.itheima.tcp;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo {

    public static void main(String[] args) throws IOException {
        //创建服务端对象
        ServerSocket ss = new ServerSocket(8848);
        //建立连接
        Socket accept = ss.accept();
        //获取输入流
        InputStream is = accept.getInputStream();
        //读数据
        int len;
        byte[] bytes= new byte[1024];
        while ((len=is.read(bytes))!=-1){
            String s = new String(bytes, 0, len);
            System.out.println(s);
        }
        //释放资源
        ss.close();


    }
}
